
import com.sun.rowset.WebRowSetImpl;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.WebRowSet;
import org.apache.lucene.analysis.en.EnglishAnalyzer;
import org.apache.lucene.analysis.id.IndonesianAnalyzer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.util.Version;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author arifnasution
 */
public class Temp {

    public static void main(String args[]) {
        try {
            String url = "jdbc:hsqldb:file:/" + System.getProperty("user.dir").substring(3) + "/database/db_conf";
            try (Connection conn = DriverManager.getConnection(url, "sa", "")) {
//                conn.setAutoCommit(true);
//                conn.createStatement().execute("CREATE TEXT TABLE currency (id INT IDENTITY PRIMARY KEY, name VARCHAR(20))");
                conn.createStatement().execute("CREATE TEXT TABLE data_a (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_b (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_c (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_d (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_e (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_f (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_g (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_h (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_i (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_j (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_k (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_l (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_m (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_n (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_o (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_p (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_q (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_r (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_s (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_t (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_u (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_v (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_w (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_x (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_y (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
                conn.createStatement().execute("CREATE TEXT TABLE data_z (id INT IDENTITY PRIMARY KEY, name varchar(100), dasar varchar(100))");
//                conn.createStatement().execute("SET TABLE currency SOURCE \"" + System.getProperty("user.dir").substring(3) + "/database/currencies.csv;ignore_first=true\"");
//                
//                WebRowSet wrs = new WebRowSetImpl();
//                wrs.setCommand("insert into currency (name) values ('')");
////                wrs.setCommand("select * from currency where id=2");
//                wrs.execute(conn);
//                while (wrs.next()) {
//                    System.out.println(wrs.getString("id") + " " + wrs.getString("name"));
//                }
                conn.close();
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

    public void testStemmer() {
        try {
            EnglishAnalyzer en_an = new EnglishAnalyzer(Version.LUCENE_36);
            IndonesianAnalyzer id_an = new IndonesianAnalyzer(Version.LUCENE_36);
            QueryParser parser = new QueryParser(Version.LUCENE_34, "your_field", en_an);
            QueryParser qp = new QueryParser(Version.LUCENE_36, "", id_an);

            String str = "waiting";
            String id_str = "menandakan";

            System.out.println("result : " + parser.parse(str));
            System.out.println("result : " + qp.parse(id_str));
        } catch (ParseException ex) {
            Logger.getLogger(Temp.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
